
#include <stdio.h>
#include "Nano100Series.h"
#include "Common.h"
#include "Input.h"
#include "EventQueue.h"

int InputReportKeyAuto(struct event_queue_t *event_queue, uint16_t code)
{
	int ret;
	struct event_t key_event;

	key_event.type = EV_KEY;
	key_event.code = code;
	key_event.value = 1;
	ret = EventQueueEnQueue(event_queue, &key_event);
	if (ret == 0) {
		key_event.type = EV_SYN;
		key_event.code = SYN_REPORT;
		key_event.value = 0;
		ret = EventQueueEnQueue(event_queue, &key_event);
		if (ret == 0) {
			key_event.type = EV_KEY;
			key_event.code = code;
			key_event.value = 0;
			ret = EventQueueEnQueue(event_queue, &key_event);
			if (ret == 0) {
				key_event.type = EV_SYN;
				key_event.code = SYN_REPORT;
				key_event.value = 0;
				ret = EventQueueEnQueue(event_queue, &key_event);
				if (ret != 0) {
					LogDebug("enqueue error\n");
					return 1;
				}
			} else {
				LogDebug("enqueue error\n");
				return 1;
			}
		} else {
			LogDebug("enqueue error\n");
			return 1;
		}
	} else {
		LogDebug("enqueue error\n");
		return 1;
	}

	return 0;
}
